<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <meta HTTP-EQUIV="Expires" CONTENT="0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>测试检测追溯</title>
<style type="text/css">
	@import "../dojo-release-1.5.0/dijit/themes/tundra/tundra.css";
	@import "../dojo-release-1.5.0/dojo/resources/dojo.css";
	@import "../dojo-release-1.5.0/dojox/grid/resources/tundraGrid.css";
</style>
<script type="text/javascript" src="../dojo-release-1.5.0/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
<script type="text/javascript" src="../framework/uiutil.js"></script>
<script type="text/javascript" src="../framework/urlutil.js"></script>
<script type="text/javascript">
dojo.addOnLoad(function(){
	initProductSelect();
	var productName = U.getValue("productName");
	var idCode = U.getValue("idCode");
	if(idCode != null && productName != null){
		 dojo.byId("idCode").value = idCode;
		 dijit.byId("productSelect").attr("value",productName);
		 dijit.byId("productSelect").attr("text",productName);
		 loadReport();
	}
});


//初始化产品选择列表
function initProductSelect(){
	dojo.xhrGet({
		 url:"../bkgrd/getProductList.do",
		 handleAs:"json",
		 preventCache:true,
		 load:function(response){
			 ps = [];
			 for(var i in response){
				 ps.push({value:response[i],name:response[i]});
			 }
			 D.initCombo("productSelect",ps)
		 }
	});
}

function loadReport(){

	if(!dijit.byId("productSelect").isValid() ||
		!dijit.byId("idCode").isValid()){
		alert("请选择产品类型并输入产品标识码（如MAC地址）进行追溯");
		return;
	}
	var product = D.getComboValue("productSelect");
	var idCode = dojo.byId("idCode").value;
	
	dojo.xhrPost({
		 url:"../bkgrd/getProductTestReport.do",
		 encoding : 'UTF-8',
		 preventCache:true,
		 content:{productName:product,idCode:idCode},
		 load:function(response){
			if(response == ""){
				alert("没有此产品的检测结果，请检查查询条件。");
			}else{
				displayReport(response);
			}
		 }
	});
}

function displayReport(reportHtml){
 	dojo.byId("testReport").innerHTML = reportHtml.replace(new RegExp("不通过","gm"),"<font color=red>不通过</font>")
 					.replace(new RegExp("未测试","gm"),"<font color=white>未测试</font>")
 					.replace(new RegExp("测试通过","gm"),"<font color=green>测试通过</font>");
 	dojo.query("#testReport > table").forEach(
 			function(tb){
 	 			tb.border = 1;
 				dojo.style(tb, { border: "1px solid",width:"100%"});
 			});
 	
}
</script>

<style type="text/css">
.testSuite{
	background-color: silver;
}
.testItem{
	background-color: silver;
	padding: 5px;
}
.testSuiteTable{
	width:100%;
}
</style>
</head>
<body class="tundra">

<table width="90%">
<tr><td>请选择产品类型：</td><td><select dojoType="dijit.form.ComboBox" id="productSelect" value="" required="true" ></select></td>
<td>产品标识码：</td><td><input type="text" dojoType="dijit.form.ValidationTextBox" id="idCode" size="30" required="true" trim="true" value=""/></td></tr>

<tr><td colspan="4" align="center"><button dojoType="dijit.form.Button" id="query" onclick="loadReport()">查询检测结果</button></td></tr>
</table>

<div id="testReport" style="border: 1px solid;height: 100%;width:95%;">

</div>
</body>
</html>